import Vue from 'vue'
import Vuex from 'vuex'

import address from './modules/address.js'
import order from './modules/order.js'

Vue.use(Vuex)

const TOKEN = "wukongzuche"

export default new Vuex.Store({
  state: {
    token: localStorage.getItem(TOKEN),
    prePage: null, // 用来记录从哪个页面跳转到的login页面
    username: "默认账号",
    nickname: "默认昵称",
    gender: "",
    birthday: "",
  },
  mutations: {
    changeToken (state,payload) {
      state.token = payload
      localStorage.setItem(TOKEN,state.token)
    },

    changePrePage(state,payload) {
      state.prePage = payload
    },

    setUsername (state,payload) {
      state.username = payload
    },

    // 设置昵称，性别，生日
    setNickname(state,payload) {
      state.nickname = payload
    },
    setBirthday(state,payload) {
      state.birthday = payload
    },
    setGender(state,payload) {
      state.gender = payload
    },
    
  },
  actions: {
  },
  modules: {
    address,
    order
  }
})
